package com.party.core.dao.read.copartner;

import com.party.common.paging.Page;
import com.party.core.dao.read.BaseReadDao;
import com.party.core.model.copartner.BrokerageItem;
import com.party.core.model.copartner.BrokerageListOutput;
import com.party.core.model.member.CopartnerAnalyzeQuery;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * @Author: Administrator.
 * @Description: 佣金流水
 * @Date:Created in 2017/10/25 0025 上午 11:54.
 */
@Repository
public interface BrokerageItemReadDao extends BaseReadDao<BrokerageItem> {
    /**
     * 佣金流水列表
     *
     * @param brokerageItem
     * @param page
     * @return
     */
    List<BrokerageListOutput> brokerageList(@Param(value = "item") BrokerageItem brokerageItem, Page page);


    /**
     * 下级合伙人佣金详情表
     * @param brokerageItem
     * @param query
     * @param page
     * @return
     */
    List<BrokerageListOutput> lowerBrokerageDetailList(@Param(value = "item") BrokerageItem brokerageItem, @Param(value = "query") CopartnerAnalyzeQuery query, Page page);

    /**
     * admin_下级合伙人佣金详情表
     * @param brokerageItem
     * @param query
     * @param page
     * @return
     */
    List<BrokerageListOutput> adminlowerBrokerageDetailList(@Param(value = "item") BrokerageItem brokerageItem, @Param(value = "query") CopartnerAnalyzeQuery query, Page page);


    /**
     * 计算佣金总额
     *
     * @param partnerId   合伙人id
     * @param checkStatus 审核状态
     * @return
     */
    Double getSumTotal(@Param(value = "partnerId") String partnerId, @Param(value = "checkStatus") Set<Integer> checkStatus);

    /**
     * 计算佣金总额
     *
     * @param parameter
     * @return
     */
    Double brokerageSum(@Param(value = "parameter") HashMap<String, Object> parameter);

    /**
     * 佣金详情
     *
     * @param itemId 佣金id
     * @return
     */
    Map<String, Object> getItemDetail(@Param(value = "itemId") String itemId);

    /**
     * 佣金流水（新）
     *
     * @param brokerageItem 请求参数
     * @param page          分页参数
     * @return
     */
    List<BrokerageListOutput> newBrokerageList(@Param(value = "item") BrokerageItem brokerageItem, Page page);

    /**
     * 获取我的佣金
     * @param params 查询参数
     * @return
     */
    Double getMyBrokerage(@Param("params") Map<String,Object> params);

    /**
     * 通过TargetId获取我的佣金
     * @param params 查询参数
     * @return
     */
    Double getMyBrokerageByTargetId(@Param("params") Map<String,Object> params);

    /**
     * 获取项目的佣金记录中可提现时间为空的
     * @param activityId 活动id
     * @return 佣金记录
     */
    List<BrokerageItem> getWithdrawDateNull(@Param("activityId") String activityId);

    List<String> distinctActivityId();
}
